package com.school.admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.school.admin.entity.MallMenuRole;
import com.school.admin.entity.MallSysRole;
import com.school.admin.mapper.MallSysRoleMapper;
import com.school.admin.service.MallMenuRoleService;
import com.school.admin.service.MallSysRoleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * <p>
 * 角色信息表 服务实现类
 * </p>
 *
 * @author sunpx
 * @since 2022-03-24
 */
@Service
public class MallSysRoleServiceImpl extends ServiceImpl<MallSysRoleMapper, MallSysRole> implements MallSysRoleService {

    @Autowired
    MallMenuRoleService mallMenuRoleService;


    @Override
    @Transactional
    public void deleteRole(String id) {
        QueryWrapper<MallMenuRole> mallMenuRoleQueryWrapper = new QueryWrapper<>();
        mallMenuRoleQueryWrapper.eq("role_id",id);
        mallMenuRoleService.remove(mallMenuRoleQueryWrapper);

        /*删除菜单中间表*/
        QueryWrapper<MallMenuRole> menuRoleQueryWrapper = new QueryWrapper<>();
        menuRoleQueryWrapper.eq("role_id",id);
        mallMenuRoleService.remove(menuRoleQueryWrapper);

        removeById(id);
    }
}
